package com.itrus.spring.inject.controller;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.itrus.spring.inject.service.DeptService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class InjectListController {
    /**
     * 核心源码实现：DefaultListableBeanFactory#resolveMultipleBeans
     */
    @Resource
    private List<DeptService> deptServiceList;

    @RequestMapping(path = "/inject/list")
    public String inject() {
        return JSON.toJSONString(deptServiceList, JSONWriter.Feature.PrettyFormat);
    }
}